#ifndef SOUND_H
#define SOUND_H
#include <QObject>
#include <QMediaPlayer>
// #include <QUrl>
// #include <QPointer>
#include <QAudioOutput>

class Sound: public QObject
{
    Q_OBJECT
public:
    explicit Sound(QObject *parent = nullptr);

    void playSound(const QString &filePath,bool loop=true);
    void setVolume(float volume);  // 设置音量 [0.0 ~ 1.0]
    float volume() const;  // 获取当前音量
    void setLoop(bool loop);  // 单独设置循环
private:
    QMediaPlayer *player;
    QAudioOutput *audioOutput;
    bool m_loop = false;  // 默认不循环
};

#endif // SOUND_H
